const { Controller } = require('egg')
class DeployController extends Controller {
    async fetchBranchesOfRepo() {
        const { ctx } = this;
        const { success, appliactionList} = await this.service.deployService.fetchBranchesOfRepo();
        ctx.body = {
            success,
            data: {
                appliactionList
            }
        }
    }
    async deployBranchOfRepo() {
        /**
         * 
         *   
         */
        const { ctx } = this;
        console.log(ctx.request.body);
        const { repo, branch } = ctx.request.body;
        if (!repo | !branch) {
            ctx.body = {
                success: false,
                errMsg: '入参不全'
            }
        }
        try {
            const { success } = this.service.deployService.deployBranch(repo, branch)
            if (!success) {
                throw "部署出错"
            }
            ctx.body = {
                success: true
            }
        } catch (err) {
            ctx.body = {
                success: false,
                errMsg: err
            }
        }

    }
}
module.exports = DeployController;